<template>
  <div class="brandMain">
    <div class="item-main">
      <div
        class="brand-list-item"
        v-for="(item, index) in bandList"
        :key="index"
      >
        <div class="top">
          <div class="lefts">
            <div class="logo">
              <img src="@/assets/矩形 2.png" alt="" />
            </div>
            <div class="user-info">
              <p>米宝宝</p>
              <div>2020-05-20 10:51:32</div>
            </div>
          </div>
          <div class="rights">
            <div class="imgs">
              <img src="@/assets/forwarding.png" alt="" />
            </div>
            <span>255</span>
          </div>
        </div>
        <div class="main">
          <p v-for="(item, index) in showdetailList" :key="index">{{ item }}</p>
          <div
            v-if="descList.length > 4"
            @click="changeFoldState(index)"
            class="unfold"
          >
            <span class="more">{{ brandFold ? '展开更多' : '收起' }} </span>
            <div class="icons" v-if="brandFold">
              <img src="@/assets/bottom.png" alt="" />
            </div>
            <div class="icons" v-else>
              <img src="@/assets/top.png" alt="" />
            </div>
          </div>
        </div>
        <div class="img-array">
          <div class="items" v-for="index in 3" :key="index"></div>
        </div>
        <div class="bottom">
          <div class="buttons">粉丝 + 212</div>
          <div class="active-buttons">
            人气转发
            <img src="@/assets/fire.png" alt="" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'brandlist',
  data() {
    return {
      descList: [
        '回购最多的爽肤水，没有之一回购最多的爽肤水',
        '超多明星网红博主自用款',
        '屈臣氏同款在售价185元',
        '券后65元1瓶50ml+3瓶20m',
        '屈臣氏同款在售价185元',
      ],
      bandList: [
        {
          brandFold: true,
        },
        {
          brandFold: true,
        },
        {
          brandFold: true,
        },
        {
          brandFold: true,
        },
      ],
      brandFold: true,
    }
  },
  computed: {
    showdetailList: {
      get: function () {
        if (this.brandFold) {
          if (this.descList.length < 5) {
            return this.descList
          }
          let newArr = []
          for (var i = 0; i < 4; i++) {
            let item = this.descList[i]
            newArr.push(item)
          }
          return newArr
        }
        return this.descList
      },
      set: function (val) {
        this.showdetailList = val
      },
    },
  },
  methods: {
    changeFoldState(index) {
      console.log(index)
      this.brandFold = !this.brandFold
    },
  },
}
</script>

<style lang="scss" scoped>
img {
  vertical-align: 12px;
}
.brandMain {
  padding: 9px 12px;
  margin: 100px 0 0;
  .item-main {
    overflow: hidden;
  }
  .brand-list-item {
    background-color: #fff;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 9px;
    .top {
      display: flex;
      justify-content: space-between;
      height: 36px;
      //line-height: 36px;
      .lefts {
        display: flex;
        .logo {
          width: 36px;
          height: 36px;
          margin-right: 10px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .user-info {
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          font-size: 11px;
          color: #afabb7;
          p {
            font-size: 13px;
            color: #1f0d44;
          }
        }
      }
      .rights {
        width: 77px;
        height: 30px;
        background: rgba(98, 44, 204, 0.1);
        border-radius: 18px;
        display: flex;
        justify-content: center;
        align-items: center;
        .imgs {
          width: 14px;
          height: 14px;
          margin-right: 2px;
          margin-top: -18px; // 注意微信和h5有差异
          img {
            width: 100%;
            height: 100%;
          }
        }
        span {
          font-size: 14px;
          color: #622ccc;
        }
      }
    }
    .main {
      font-size: 14px;
      margin: 8px 0 15px;
      //display: flex;
      .unfold {
        display: flex;
        align-items: center;
        .icons {
          width: 10px;
          height: 6px;
          margin-left: 4px;
          margin-top: -4px;
          img {
            width: 100%;
            vertical-align: 10px;
          }
        }
      }
    }
    .img-array {
      display: flex;
      justify-content: space-between;
      margin-bottom: 15px;
      .items {
        width: 105px;
        height: 105px;
        background-color: hotpink;
        border-radius: 8px;
      }
    }
  }
}
.bottom {
  display: flex;
  font-size: 14px;
  text-align: center;
  line-height: 30px;
  color: #fff;
  .buttons {
    width: 94px;
    height: 30px;
    background: rgba(98, 44, 204, 0.1);
    border-radius: 15px;
    margin-right: 20px;
    color: #622ccc;
  }
  .active-buttons {
    width: 94px;
    height: 30px;
    background: linear-gradient(135deg, #ff5bf4 0%, #622ccc 100%);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    img {
      width: 12px;
      height: 15px;
      margin: auto 0 auto 2px;
    }
  }
}
.more {
  color: #1677ff;
}
</style>